package com.campus.happy;

import android.content.Context;
import android.support.v4.view.ViewPager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.LinearLayout.LayoutParams;

public class TabPager extends LinearLayout implements OnPageChangeListener {
	public ViewPager vp;
	public Indicator indicator;

	public TabPager(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
		vp = new ViewPager(context);
		indicator = new Indicator(context);
		setOrientation(LinearLayout.VERTICAL);
		
		
		for (int i = 0; i < 10; i++) {
			TextView textview = new TextView(context);
             LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(150,LinearLayout.LayoutParams.FILL_PARENT);
			lp.leftMargin=10;
			lp.rightMargin=10;
             textview.setText("ssss"+i);
			indicator.addView(textview,lp);
		}
		vp.setOnPageChangeListener(this);
		HorizontalScrollView s=new HorizontalScrollView(context);
		s.addView(indicator);
		s.setScrollbarFadingEnabled(true);
		s.setHorizontalScrollBarEnabled(false);
		addView(s);
		addView(vp);
		indicator.scroll(5, 0);
	}

	@Override
	public void onPageScrollStateChanged(int arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onPageScrolled(int arg0, float arg1, int arg2) {
		// TODO Auto-generated method stub
		indicator.scroll(arg0, arg1);
	}

	@Override
	public void onPageSelected(int arg0) {
		// TODO Auto-generated method stub
		
	}

}
